package com.twu.biblioteca;
import java.io.Serializable;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: kush jain
 * Date: 7/4/13
 * Time: 9:38 PM
 * To change this template use File | Settings | File Templates.
 */
public class Movie implements Serializable {
    String movieName;
    int year;
    String director;
    int rating;
    Movie()
    {
        rating =Constants.NOT_RATED;
        director = new String();
        movieName = new String();
        year = Calendar.getInstance().get(Calendar.YEAR);
    }
    Movie(String movieName, int year, String director, int rating)
    {
        this.movieName=movieName;
        this.year=year;
        this.director=director;
        this.rating=rating;
    }
    public String displayRating()
    {
           if (rating==Constants.NOT_RATED)
                return Constants.NOT_RATED_STR;
           String ratingStr="";
           for(int i=1;i<=rating;i++)
                  ratingStr += "*";
            return ratingStr;
    }
    public void setRating(int rating)
    {
        this.rating =rating;
    }

    public String print()
    {
          return String.format("%-30s\t%4d\t%-30s\t%-10s",movieName,year,director,displayRating());
    }

}
